CSCN8010-Lab_2 (Matplotlib, Seaborn, Plotly)¶

Graph-1 (By making use of Matplotlib)¶

By using this Source¶

https://matplotlib.org/stable/plot_types/3D/surface3d_simple.html#sphx-glr-plot-types-3d-surface3d-simple-py

In [2]:
import matplotlib.pyplot as plt
import numpy as np

from matplotlib import cm

plt.style.use('_mpl-gallery')

# Make data
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)

# Plot the surface
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
ax.plot_surface(X, Y, Z, vmin=Z.min() * 2, cmap=cm.Blues)

ax.set(xticklabels=[],
       yticklabels=[],
       zticklabels=[])

plt.show()

This code produces a 3D plot of the sine function on a grid, resulting in a blue, Wavy surface.

Graph-2 (By making use of Seaborn)¶

By using this Source¶

https://seaborn.pydata.org/examples/grouped_boxplot.html

In [3]:
import seaborn as sns
sns.set_theme(style="ticks", palette="pastel")

# Load the example tips dataset
tips = sns.load_dataset("tips")

# Draw a nested boxplot to show bills by day and time
sns.boxplot(x="day", y="total_bill",
            hue="smoker", palette=["m", "g"],
            data=tips)
sns.despine(offset=10, trim=True)

This describes the distribution of total bills across days, differentiated by smoker status, with a pastel color palette and tick styling, using the "tips" dataset.

Graph-3 (By making use of Plotly)¶

By using this Source¶

https://plotly.com/python/plotly-express/#gallery

In [1]:
import plotly
plotly.offline.init_notebook_mode()
In [3]:
import plotly.express as px
df = px.data.gapminder()
fig = px.scatter(df.query("year==2007"), x="gdpPercap", y="lifeExp", size="pop", color="continent",
           hover_name="country", log_x=True, size_max=60)
fig.show()

This is used to generate an interactive scatter plot of GDP per capita against life expectancy for the year 2007, with marker size representing population, color indicating continent, and a logarithmic x-axis scale.

TABLE¶

Name Age Occupation Location
Sumit 30 Teacher Waterloo, Canada
Sourabh 20 Computer technician Waterloo, Canada
Paras 19 Student Waterloo, Canada
Lakshay 26 Data Analyst Waterloo, Canada

Our mission